Fix: Use consistent cursor height instead of per-character metrics#1182
Open
JimTyrrell wants to merge 5 commits into
Open
Fix: Use consistent cursor height instead of per-character metrics#1182JimTyrrell wants to merge 5 commits into
JimTyrrell wants to merge 5 commits into
Conversation
|
Jim Tyrrell seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
The cursor height was calculated using getFullHeightForCaret() which returns different heights depending on the character at the cursor position. This caused the cursor to appear shorter when positioned after spaces compared to letters, especially noticeable on iOS. This fix uses a consistent formula (fontSize * 1.2) to ensure the cursor height remains stable regardless of the character at the cursor position. Fixes AppFlowy-IO#1137
7ae10e1 to
bc7fbe1
Compare
AppFlowyClipboard was a plain-text-only stub: setData dropped the `html` argument and getData hard-coded `html: null`. With no html on the clipboard, the editor's paste handler skipped its formatting-preserving `pasteHtml` branch and fell back to a bare plain-text delta — so copy→paste of formatted text (bold/italic/lists/headings) lost ALL formatting, even within the same app. Retain the last copied html in-process and return it on getData only when the system clipboard still holds the matching text we wrote (same-app copy→paste round trip); otherwise return html:null so external plain-text paste degrades gracefully. The system clipboard still receives text/plain as before, so cross-app plain paste is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The HTML encoder appended a list item's child list nodes (bare <li>) directly inside the parent <li> with no enclosing <ol>/<ul>. The emitted markup (<li>parent<li>child</li></li>) is "fixed" by every HTML parser by flattening the inner <li> into a sibling — so a nested list item lost its indent level and was renumbered to top level on copy/paste. Add processChildrenNodesPreservingListNesting (wraps consecutive same-type list children in their own <ol>/<ul>; non-list children pass through) and use it from the numbered + bulleted list parsers. Only affects lists WITH children (nested), so flat lists are unchanged. Checkbox/todo nesting is unchanged (separate follow-up). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The encoder emits a to-do item as <div><input type="checkbox" [checked]/>text </div>, but the decoder had no handler: <div> fell through to the default (plain paragraph) and the <input> was ignored — so pasting a checklist lost both the todo_list block type and the checked state. Add _parseDivElement: when a <div> contains a checkbox <input>, build a todo_list node carrying the checked state and the remaining inline content; otherwise fall back to paragraph parsing (non-todo divs unaffected). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem
The cursor height was calculated using
getFullHeightForCaret()which returns different heights depending on the character at the cursor position. Spaces have different text metrics than letters, causing the cursor to "jump" or change height as you type.Solution
Replace the dynamic
getFullHeightForCaret()call with a consistent formula based on font size:This ensures the cursor height remains stable regardless of the character at the cursor position.
Related Issues
Fixes #1137
Related to #1136, #624
Test Plan